package com.ogawa.a7517.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ogawa.a7517.R;
import com.ogawa.a7517.bean.ProgramBean;

import java.util.List;

public class MainAdapter extends BaseQuickAdapter<ProgramBean, BaseViewHolder> {
    private int running;

    public MainAdapter(List<ProgramBean> data) {
        super(R.layout.layout_program_item, data);
    }

    public void setRunning(int running) {
        if (this.running!=running){
            this.running = running;
            notifyDataSetChanged();
        }
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ProgramBean item) {
        helper.setImageResource(R.id.iv_program, item.getImgRes());
        helper.getView(R.id.iv_program).setSelected(running == item.getModel());
        helper.itemView.setSelected(running == item.getModel());
    }
}
